package com.free.semantic.core.businessfunction.impl;

import com.free.semantic.common.RangeObj;
import com.free.semantic.core.Context;
import com.free.semantic.core.businessfunction.BasicFunction;
import com.google.common.collect.Lists;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class EmailToUser implements BasicFunction {


    Map<String, String> testData = new HashMap<>();

    @PostConstruct
    public void init() {
        testData.put("1666732060@qq.com", "逍遥游");
    }

    @Override
    public List<RangeObj> require() {
        return Lists.newArrayList(RangeObj.one("邮箱"));
    }

    @Override
    public RangeObj provider() {
        return RangeObj.one("用户");
    }

    @Override
    public void calculate(Context context) {
        List<String> email = context.getListValue("邮箱");
        context.setValue("用户", testData.get(email.get(0)));
    }
}
